<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>简单表单示例</title>
<script>
  //2
  function check(){
    var email = document.getElementById('email')
    if(email.value == ''){
      alert('请输入Email地址')
      return false
    }else{
      alert('你输入的Email地址有效')
    }
  }
</script>
</head>

<body>
  <h2>表单验证</h2>
  <!-- 1.required内容不允许为空
  2.正则表达式格式验证
  3.min , max 数值和日期类型元素 专用属性
  4.step , input元素增，减时间隔 -->
  <form name="form1" method="post">
    <input name="t1" required pattern="^\w.*$" placeholder="字符开头"/>
    <br />
    <input name="part" pattern="[0-9][A-Z]{3}" placeholder="一个数字三个字母" />
    <br />
    <input type="submit" />
  </form>

  <hr />

  <!-- 2 -->
  <form onsubmit="return check()">
    <label for="email">Email</label>
    <input name="email" id="email" type="email" /><br />
    <input type="submit" />
  </form>
</body>
</html>















<!---->
